<?php

namespace app\admin\validate;

use think\Validate;

class Roles extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */	
	protected $rule = [
	    'ids|标识列表' => 'require|array',
	    'name|角色名称' => 'chsDash',
        'status|状态' => 'in:0,1',
        'start_sort_num|排序值开始范围' => 'integer',
        'end_sort_num|排序值结束范围' => 'integer'
    ];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */	
    protected $message = [];

    /**
     * 场景验证
     * @var []
     */
    protected $scene = [
        'index' => ['name','status','start_sort_num','end_sort_num']
    ];

    /**
     * 定义验证新增场景验证
     * @return $this
     */
    public function sceneCreate()
    {
        return $this->only(['name','description', 'status','permission_id','sort_num'])
            ->append('name', 'require')
            ->append('status', 'require')
            ->append('category_id', 'require');
    }

    /**
     * 定义验证编辑场景验证
     * @return $this
     */
    public function sceneUpdate()
    {
        return $this->only(['name','description', 'status','permission_id','sort_num'])
            ->append('name', 'require')
            ->append('status', 'require')
            ->append('category_id', 'require');
    }

}
